﻿@model App.Web.ViewModels.CategoryViewModel
@using App.Web.Utility;
@using App.Core.Extensions;
@using App.Web.ViewModels.UtilityModels;
@{
    String pageTitle = "Products by Category";
    ListConfig _ListConfig = ViewData[AppConstants.ViewDataKeys.SUB_MODEL] as ListConfig;
    ViewBag.DataSource = _ListConfig.DataSource;
    ViewBag.TotalRecord = _ListConfig.Pager.TotalRecord;
    _ListConfig.Pager.UrlFormat = "/product/category/" + Model.UrlName + "?pageno={0}";
    if(Model == null){
        ViewBag.Title = Html.GetPageTitle(pageTitle);    
    }
    else{
        pageTitle = String.Format("Products by Category {0}", Model.Name);     
        ViewBag.Title = Html.GetPageTitle(pageTitle);
    }    
}

<div class="page-heading">
    <h1>@pageTitle</h1>
    <div>@if(Model != null){
        @:Showing all products from the category <strong>@Model.Name</strong> 
        }
    </div>
</div>
<div class="GroupBox">    
    <div class="text" style="text-align: right">
        <span class="span-compare" style="cursor: pointer;" onclick="GoComparePage();">Compare(@SessionCache.ProductCompareList.Count)</span>
    </div>
    @if (Model == null)
    {
        @Html.InfoMessageBox("Sorry! the requested Category was not found")
    }
    else
    {
        @Html.Partial("_ProductList")
    }        
    @Html.Partial("_Pager", _ListConfig.Pager)    
</div>